namespace CGF
{
    public partial class Wait : UIComponentBase, IAwake<UILayer, bool>, IDestroy
    {
        public static void Open(float duartion = 30)
        {
            UIManagerComponent.instance.OpenUI<Wait>(UILayer.Top, RootComponent.instance, true).AutoClose(duartion);
        }

        public static void Close()
        {
            UIManagerComponent.instance.CloseUI<Wait>();
        }

        private async void AutoClose(float delay)
        {
            await CTask.Wait(delay);
            Close();
        }

        public async void Awake(UILayer layer, bool isFloat)
        {
            await SpawnPrefab("Prefabs/Common/Wait", layer, isFloat);
        }
    }
}
